package operation;

import data.Data;
import data.DataBase;

public class SearchResult implements IOperation {
    @Override
    public void work(DataBase dataBase) {
        System.out.println("检测报告查询！");
        System.out.print("请输入你的姓名：");
        String name = scanner.nextLine();
        System.out.print("请输入你的身份证号：");
        String id = scanner.nextLine();

        int currentSize=dataBase.getContainSize();
        for (int i = 0; i < currentSize; i++) {
            Data data = dataBase.getData(i);
            if (data.getId().equals(id)) {
                if (!data.isSampled()) {
                    System.out.println("当前状态：未采样");
                    return;
                }
                if (!data.isChecked()) {
                    System.out.println("当前状态：未检测");
                    return;
                }
                System.out.println("┌-----------------------------┐");
                System.out.println("你好 "+name+" 您的核酸检测信息如下：");
                System.out.println("身份证号："+id);
                System.out.println("检测机构："+dataBase.getCheckInstation());
                System.out.println("检测结果："+(!data.isNegative()?"阴性":"阳性"));

                System.out.println("└-----------------------------┘");

            }
        }

    }

}
